<?php

namespace app\admin\controller;

use think\Db;

class UserAudit extends Common
{
    public function user_device_warn()
    {
        $where = [];

        $search_name = input('param.name');
        $search_type = input('param.search');
        if ($search_name && $search_type) {
            if(in_array($search_type, ['user_id'])){
                $where[$search_type] = $search_name;
            }
        }

        $data = Db::name('user_device_warn')->where($where)->field('*')->order('id desc')->paginate(_getCachePages(), false, ['query' => request()->param()]);

        $list = $data->all();
        $users = Db::name('user')->where(['id'=>['in',array_column($list,'user_id')]])->column('name,yqr,realname_auth', 'id');
        foreach ($list as $k => $v) {
            $list[$k]['realname_auth'] = 1;
            if (isset($users[$v['user_id']])) {
                $list[$k]['realname_auth'] = $users[$v['user_id']]['realname_auth'];
                $list[$k]['name'] = $users[$v['user_id']]['name'];
            }
        }
        $this->assign('data', $list);

        $page = $data->render();
        $this->assign('page', $page);
        return $this->fetch();
    }
}